package gui.win.veme;

import core.utils.Utils;
import gui.Segl1;
import gui.processor.Processor;
import gui.processor.Worker;
import gui.utils.Para;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;

/*Author: John Archer, Contact: john.archer.jpa@gmail.com*/
public class Buttons extends JPanel implements ActionListener{
    private JButton close, create;
    private Veme fullT;
    private Segl1 Segl1;
    public Buttons(Veme fullT, Segl1 Segl1){
        super(new BorderLayout());
        this.setBorder(BorderFactory.createEmptyBorder(0,6,6,6));
        this.fullT = fullT;
        this.Segl1 = Segl1;
        this.add(Utils.getButton(close = new JButton("CANCEL"), 180, 25, new Color(102, 102, 102), new Color(178, 178, 178), this, "Cancel"), BorderLayout.WEST);
        this.add(Utils.getButton(create = new JButton("SAVE"), 180, 25, new Color(102, 102, 102), new Color(178, 178, 178), this, "Save Veme Table"), BorderLayout.EAST);
        this.setVisible(true);
    }

    public void actionPerformed(ActionEvent evt) {
        Object source = evt.getSource();
        if(source == close){fullT.dispose();}
        else if(source == create){
            Processor guip = new Processor(Segl1);
            guip.setTask(Para.TASK_VEME);
            Worker sl = new Worker(guip);
            sl.execute();
            fullT.dispose();
        }
    }
    public void closeFrame(){fullT.closeFrame();}
}